home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 July: Mac OS SDK / Dev.CD Jul 99 SDK1.toast / Development Kits / Mac OS / Interfaces&Libraries / Universal / Interfaces / PInterfaces / JManager.p < prev    next >
Encoding:
Text File  |  1998-08-17  |  27.7 KB  |  686 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        JManager.p
  3.  
  4.      Contains:    Routines that can be used to invoke the Java Virtual Machine in MRJ 
  5.  
  6.      Version:    Technology:    MRJ 2.1
  7.                  Release:    Universal Interfaces 3.2
  8.  
  9.      Copyright:    © 1996-1998 by Apple Computer, Inc., all rights reserved.
  10.  
  11.      Bugs?:        For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. }
  17. {$IFC UNDEFINED UsingIncludes}
  18. {$SETC UsingIncludes := 0}
  19. {$ENDC}
  20.  
  21. {$IFC NOT UsingIncludes}
  22.  UNIT JManager;
  23.  INTERFACE
  24. {$ENDC}
  25.  
  26. {$IFC UNDEFINED __JMANAGER__}
  27. {$SETC __JMANAGER__ := 1}
  28.  
  29. {$I+}
  30. {$SETC JManagerIncludes := UsingIncludes}
  31. {$SETC UsingIncludes := 1}
  32.  
  33. {$IFC UNDEFINED __CONDITIONALMACROS__}
  34. {$I ConditionalMacros.p}
  35. {$ENDC}
  36. {$IFC UNDEFINED __MACTYPES__}
  37. {$I MacTypes.p}
  38. {$ENDC}
  39. {$IFC UNDEFINED __FILES__}
  40. {$I Files.p}
  41. {$ENDC}
  42. {$IFC UNDEFINED __DRAG__}
  43. {$I Drag.p}
  44. {$ENDC}
  45. {$IFC UNDEFINED __QUICKDRAW__}
  46. {$I Quickdraw.p}
  47. {$ENDC}
  48. {$IFC UNDEFINED __MENUS__}
  49. {$I Menus.p}
  50. {$ENDC}
  51. {$IFC UNDEFINED __TEXTCOMMON__}
  52. {$I TextCommon.p}
  53. {$ENDC}
  54.  
  55.  
  56. {$PUSH}
  57. {$ALIGN MAC68K}
  58. {$LibExport+}
  59.  
  60.  
  61.  
  62. CONST
  63.     kJMVersion                    = $11000003;                    {  using Sun's 1.1 APIs, our current APIs.  }
  64.     kDefaultJMTime                = $00000400;                    {  how much time to give the JM library on "empty" events, in milliseconds.  }
  65.  
  66.     kJMVersionError                = -60000;
  67.     kJMExceptionOccurred        = -60001;
  68.     kJMBadClassPathError        = -60002;
  69.  
  70. {
  71.  *    Private data structures
  72.  *
  73.  *    JMClientData        - enough bits to reliably store a pointer to arbitrary, client-specific data. 
  74.  *    JMSessionRef        - references the entire java runtime 
  75.  *    JMTextRef            - a Text string, length, and encoding 
  76.  *    JMTextEncoding        - which encoding to use when converting in and out of Java strings.
  77.  *    JMFrameRef            - a java frame 
  78.  *    JMAWTContextRef     - a context for the AWT to request frames, process events 
  79.  *    JMAppletLocatorRef    - a device for locating, fetching, and parsing URLs that may contain applets 
  80.  *    JMAppletViewerRef    - an object that displays applets in a Frame 
  81.  }
  82.  
  83. TYPE
  84.     JMClientData                        = Ptr;
  85.     JMSessionRef = ^LONGINT;
  86.     JMFrameRef = ^LONGINT;
  87.     JMTextRef = ^LONGINT;
  88.     JMAWTContextRef = ^LONGINT;
  89.     JMAppletLocatorRef = ^LONGINT;
  90.     JMAppletViewerRef = ^LONGINT;
  91.     JMTextEncoding                        = TextEncoding;
  92.  
  93. {
  94.  * The runtime requires certain callbacks be used to communicate between
  95.  * session events and the embedding application.
  96.  *
  97.  * In general, you can pass nil as a callback and a "good" default will be used.
  98.  *
  99.  *    JMConsoleProcPtr          - redirect stderr or stdout - the message is delivered in the encoding specified when
  100.  *                                you created the session, or possibly binary data.
  101.  *    JMConsoleReadProcPtr     - take input from the user from a console or file.  The input is expected to 
  102.  *                                be in the encoding specified when you opened the session.
  103.  *    JMExitProcPtr              - called via System.exit(int), return "true" to kill the current thread,
  104.  *                                false, to cause a 'QUIT' AppleEvent to be sent to the current process,
  105.  *                                or just tear down the runtime and exit to shell immediately
  106.  * JMLowMemoryProcPtr          - This callback is available to notify the embedding application that
  107.  *                                a low memory situation has occurred so it can attempt to recover appropriately.
  108.  * JMAuthenicateURLProcPtr  - prompt the user for autentication based on the URL.  If you pass
  109.  *                                nil, JManager will prompt the user.  Return false if the user pressed cancel.
  110.  }
  111. {$IFC TYPED_FUNCTION_POINTERS}
  112.     JMConsoleProcPtr = PROCEDURE(session: JMSessionRef; message: UNIV Ptr; messageLengthInBytes: UInt32); C;
  113. {$ELSEC}
  114.     JMConsoleProcPtr = ProcPtr;
  115. {$ENDC}
  116.  
  117. {$IFC TYPED_FUNCTION_POINTERS}
  118.     JMConsoleReadProcPtr = FUNCTION(session: JMSessionRef; buffer: UNIV Ptr; maxBufferLength: SInt32): SInt32; C;
  119. {$ELSEC}
  120.     JMConsoleReadProcPtr = ProcPtr;
  121. {$ENDC}
  122.  
  123. {$IFC TYPED_FUNCTION_POINTERS}
  124.     JMExitProcPtr = FUNCTION(session: JMSessionRef; status: SInt32): BOOLEAN; C;
  125. {$ELSEC}
  126.     JMExitProcPtr = ProcPtr;
  127. {$ENDC}
  128.  
  129. {$IFC TYPED_FUNCTION_POINTERS}
  130.     JMAuthenticateURLProcPtr = FUNCTION(session: JMSessionRef; url: ConstCStringPtr; realm: ConstCStringPtr; VAR userName: CHAR; VAR password: CHAR): BOOLEAN; C;
  131. {$ELSEC}
  132.     JMAuthenticateURLProcPtr = ProcPtr;
  133. {$ENDC}
  134.  
  135. {$IFC TYPED_FUNCTION_POINTERS}
  136.     JMLowMemoryProcPtr = PROCEDURE(session: JMSessionRef); C;
  137. {$ELSEC}
  138.     JMLowMemoryProcPtr = ProcPtr;
  139. {$ENDC}
  140.  
  141.     JMSessionCallbacksPtr = ^JMSessionCallbacks;
  142.     JMSessionCallbacks = RECORD
  143.         fVersion:                UInt32;                                    {  should be set to kJMVersion  }
  144.         fStandardOutput:        JMConsoleProcPtr;                        {  JM will route "stdout" to this function.  }
  145.         fStandardError:            JMConsoleProcPtr;                        {  JM will route "stderr" to this function.  }
  146.         fStandardIn:            JMConsoleReadProcPtr;                    {  read from console - can be nil for default behavior (no console IO)  }
  147.         fExitProc:                JMExitProcPtr;                            {  handle System.exit(int) requests  }
  148.         fAuthenticateProc:        JMAuthenticateURLProcPtr;                {  present basic authentication dialog  }
  149.         fLowMemProc:            JMLowMemoryProcPtr;                        {  Low Memory notification Proc  }
  150.     END;
  151.  
  152.     JMVerifierOptions             = LONGINT;
  153. CONST
  154.     eDontCheckCode                = {JMVerifierOptions}0;
  155.     eCheckRemoteCode            = {JMVerifierOptions}1;
  156.     eCheckAllCode                = {JMVerifierOptions}2;
  157.  
  158.  
  159. {
  160.  * JMRuntimeOptions is a mask that allows you to specify certain attributes
  161.  * for the runtime. Bitwise or the fields together, or use one of the "premade" entries.
  162.  * eJManager2Defaults is the factory default, and best bet to use.
  163.  }
  164.  
  165. TYPE
  166.     JMRuntimeOptions             = LONGINT;
  167. CONST
  168.     eJManager2Defaults            = {JMRuntimeOptions}0;
  169.     eUseAppHeapOnly                = {JMRuntimeOptions}$01;
  170.     eDisableJITC                = {JMRuntimeOptions}$02;
  171.     eEnableDebugger                = {JMRuntimeOptions}$04;
  172.     eDisableInternetConfig        = {JMRuntimeOptions}$08;
  173.     eInhibitClassUnloading        = {JMRuntimeOptions}$10;
  174.     eEnableProfiling            = {JMRuntimeOptions}$20;
  175.     eJManager1Compatible        = {JMRuntimeOptions}$18;
  176.  
  177.  
  178.  
  179.  
  180. {
  181.  * Returns the version of the currently installed JManager library.
  182.  * Compare to kJMVersion.  This is the only call that doesn't
  183.  * require a session, or a reference to something that references
  184.  * a session.
  185.  }
  186. FUNCTION JMGetVersion: UInt32; C;
  187. {
  188.  * JMOpenSession creates a new Java Runtime.  Note that JManger 2.0 doesn't set 
  189.  * security options at the time of runtime instantiation.  AppletViewer Objecs have
  190.  * seperate security attributes bound to them, and the verifier is availiable elsewhere
  191.  * as well.  The client data parameter lets a client associate an arbitgrary tagged pointer
  192.  * with the seession.
  193.  * When you create the session, you must specify the desired Text Encoding to use for
  194.  * console IO.  Usually, its OK to use "kTextEncodingMacRoman".  See TextCommon.h for the list.
  195.  }
  196. FUNCTION JMOpenSession(VAR session: JMSessionRef; runtimeOptions: JMRuntimeOptions; verifyMode: JMVerifierOptions; {CONST}VAR callbacks: JMSessionCallbacks; desiredEncoding: JMTextEncoding; data: JMClientData): OSStatus; C;
  197. FUNCTION JMCloseSession(session: JMSessionRef): OSStatus; C;
  198.  
  199. {
  200.  * Client data getter/setter functions.
  201.  }
  202. FUNCTION JMGetSessionData(session: JMSessionRef; VAR data: JMClientData): OSStatus; C;
  203. FUNCTION JMSetSessionData(session: JMSessionRef; data: JMClientData): OSStatus; C;
  204.  
  205. {
  206.  * Prepend the target of the FSSpec to the class path.
  207.  * If a file, .zip or other known archive file - not a .class file
  208.  }
  209. FUNCTION JMAddToClassPath(session: JMSessionRef; {CONST}VAR spec: FSSpec): OSStatus; C;
  210.  
  211. {
  212.  * Utility returns (client owned) null terminated handle containing "file://xxxx", or nil if fnfErr
  213.  }
  214. FUNCTION JMFSSToURL(session: JMSessionRef; {CONST}VAR spec: FSSpec): Handle; C;
  215.  
  216. {
  217.  * Turns "file:///disk/file" into an FSSpec.  other handlers return paramErr
  218.  }
  219. FUNCTION JMURLToFSS(session: JMSessionRef; urlString: JMTextRef; VAR spec: FSSpec): OSStatus; C;
  220.  
  221. {
  222.  * JMIdle gives time to all Java threads. Giving more time makes Java programs run faster,
  223.  * but can reduce overall system responsiveness. JMIdle will return sooner if low-level (user)
  224.  * events appear in the event queue.
  225.  }
  226. FUNCTION JMIdle(session: JMSessionRef; jmTimeMillis: UInt32): OSStatus; C;
  227.  
  228. {
  229.  * Java defines system-wide properties that applets can use to make queries about the
  230.  * host system. Many of these properties correspond to defaults provided by "Internet Config."
  231.  * JMPutSessionProperty can be used by a client program to modify various system-wide properties.
  232.  }
  233. FUNCTION JMGetSessionProperty(session: JMSessionRef; propertyName: JMTextRef; VAR propertyValue: JMTextRef): OSStatus; C;
  234. FUNCTION JMPutSessionProperty(session: JMSessionRef; propertyName: JMTextRef; propertyValue: JMTextRef): OSStatus; C;
  235.  
  236. {
  237.  * JMText: opaque object that encapsulates a string, length, and
  238.  * character encoding.  Strings passed between JManager and the
  239.  * embedding application goes through this interface.  Only the most
  240.  * rudimentary conversion routines are supplied - it is expected that
  241.  * the embedding application will most of its work in the System Script.
  242.  *
  243.  * These APIs present some questions about who actually owns the 
  244.  * JMText.  The rule is, if you created a JMTextRef, you are responsible
  245.  * for deleting it after passing it into the runtime.  If the runtime passes
  246.  * one to you, it will be deleted after the callback.
  247.  *
  248.  * If a pointer to an uninitialised JMTextRef is passed in to a routine (eg JMGetSessionProperty),
  249.  * it is assumed to have been created for the caller, and it is the callers responsibility to
  250.  * dispose of it.
  251.  *
  252.  * The encoding types are taken verbatim from the Text Encoding Converter,
  253.  * which handles the ugly backside of script conversion.
  254.  }
  255. {
  256.  * JMNewTextRef can create from a buffer of data in the specified encoding
  257.  }
  258. FUNCTION JMNewTextRef(session: JMSessionRef; VAR textRef: JMTextRef; encoding: JMTextEncoding; charBuffer: UNIV Ptr; bufferLengthInBytes: UInt32): OSStatus; C;
  259.  
  260. {
  261.  * JMCopyTextRef clones a text ref.
  262.  }
  263. FUNCTION JMCopyTextRef(textRefSrc: JMTextRef; VAR textRefDst: JMTextRef): OSStatus; C;
  264.  
  265. {
  266.  * Disposes of a text ref passed back from the runtime, or created explicitly through JMNewTextRef
  267.  }
  268. FUNCTION JMDisposeTextRef(textRef: JMTextRef): OSStatus; C;
  269.  
  270. {
  271.  * Returns the text length, in characters
  272.  }
  273. FUNCTION JMGetTextLength(textRef: JMTextRef; VAR textLengthInCharacters: UInt32): OSStatus; C;
  274.  
  275. {
  276.  * Returns the text length, in number of bytes taken in the destination encoding
  277.  }
  278. FUNCTION JMGetTextLengthInBytes(textRef: JMTextRef; dstEncoding: JMTextEncoding; VAR textLengthInBytes: UInt32): OSStatus; C;
  279.  
  280. {
  281.  * Copies the specified number of characters to the destination buffer with the appropriate
  282.  * destination encoding.
  283.  }
  284. FUNCTION JMGetTextBytes(textRef: JMTextRef; dstEncoding: JMTextEncoding; textBuffer: UNIV Ptr; textBufferLength: UInt32; VAR numCharsCopied: UInt32): OSStatus; C;
  285.  
  286. {
  287.  * Returns a Handle to a null terminated, "C" string in the System Script.
  288.  }
  289. FUNCTION JMTextToMacOSCStringHandle(textRef: JMTextRef): Handle; C;
  290.  
  291.  
  292.  
  293. {
  294.  * Proxy properties in the runtime.
  295.  *
  296.  * These will only be checked if InternetConfig isn't used to specify properties,
  297.  * or if it doesn't have the data for these.
  298.  }
  299.  
  300. TYPE
  301.     JMProxyInfoPtr = ^JMProxyInfo;
  302.     JMProxyInfo = RECORD
  303.         useProxy:                BOOLEAN;
  304.         proxyHost:                PACKED ARRAY [0..254] OF CHAR;
  305.         proxyPort:                UInt16;
  306.     END;
  307.  
  308.     JMProxyType                 = LONGINT;
  309. CONST
  310.     eHTTPProxy                    = {JMProxyType}0;
  311.     eFirewallProxy                = {JMProxyType}1;
  312.     eFTPProxy                    = {JMProxyType}2;
  313.  
  314. FUNCTION JMGetProxyInfo(session: JMSessionRef; proxyType: JMProxyType; VAR proxyInfo: JMProxyInfo): OSStatus; C;
  315. FUNCTION JMSetProxyInfo(session: JMSessionRef; proxyType: JMProxyType; {CONST}VAR proxyInfo: JMProxyInfo): OSStatus; C;
  316.  
  317. {
  318.  * Security - JManager 2.0 security is handled on a per-applet basis.
  319.  * There are some security settings that are inherited from InternetConfig
  320.  * (Proxy Servers) but the verifier can now be enabled and disabled.
  321.  }
  322. FUNCTION JMGetVerifyMode(session: JMSessionRef; VAR verifierOptions: JMVerifierOptions): OSStatus; C;
  323. FUNCTION JMSetVerifyMode(session: JMSessionRef; verifierOptions: JMVerifierOptions): OSStatus; C;
  324.  
  325.  
  326.  
  327. {
  328.  * The basic unit of AWT interaction is the JMFrame.  A JMFrame is bound to top level
  329.  * awt Frame, Window, or Dialog.  When a user event occurs for a MacOS window, the event is passed
  330.  * to the corrosponding frame object.  Similarly, when an AWT event occurs that requires the
  331.  * Mac OS Window to change, a callback is made.  JManager 1.x bound the frame to the window through
  332.  * a callback to set and restore the windows GrafPort.  In JManager 2.0, a GrafPort, Offset, and 
  333.  * ClipRgn are specified up front - changes in visibility and structure require that these be re-set.
  334.  * This enables support for the JavaSoft DrawingSurface API - and also improves graphics performance.
  335.  * You should reset the graphics attributes anytime the visiblity changes, like when scrolling.
  336.  * You should also set it initially when the AWTContext requests the frame.
  337.  * At various times, JM will call back to the client to register a new JMFrame, 
  338.  * indicating the frame type.  The client should take the following steps:
  339.  *
  340.  *    o    Create a new invisible window of the specified type
  341.  *    o    Fill in the callbacks parameter with function pointers
  342.  *    o    Do something to bind the frame to the window (like stuff the WindowPtr in the JMClientData of the frame)
  343.  *    o    Register the visiblity parameters (GrafPtr, etc) with the frame
  344.  }
  345.  
  346. TYPE
  347.     ReorderRequest                 = LONGINT;
  348. CONST
  349.     eBringToFront                = {ReorderRequest}0;            {  bring the window to front  }
  350.     eSendToBack                    = {ReorderRequest}1;            {  send the window to back  }
  351.     eSendBehindFront            = {ReorderRequest}2;            {  send the window behind the front window  }
  352.  
  353.  
  354. TYPE
  355. {$IFC TYPED_FUNCTION_POINTERS}
  356.     JMSetFrameSizeProcPtr = PROCEDURE(frame: JMFrameRef; {CONST}VAR newBounds: Rect); C;
  357. {$ELSEC}
  358.     JMSetFrameSizeProcPtr = ProcPtr;
  359. {$ENDC}
  360.  
  361. {$IFC TYPED_FUNCTION_POINTERS}
  362.     JMFrameInvalRectProcPtr = PROCEDURE(frame: JMFrameRef; {CONST}VAR r: Rect); C;
  363. {$ELSEC}
  364.     JMFrameInvalRectProcPtr = ProcPtr;
  365. {$ENDC}
  366.  
  367. {$IFC TYPED_FUNCTION_POINTERS}
  368.     JMFrameShowHideProcPtr = PROCEDURE(frame: JMFrameRef; showFrameRequested: BOOLEAN); C;
  369. {$ELSEC}
  370.     JMFrameShowHideProcPtr = ProcPtr;
  371. {$ENDC}
  372.  
  373. {$IFC TYPED_FUNCTION_POINTERS}
  374.     JMSetTitleProcPtr = PROCEDURE(frame: JMFrameRef; title: JMTextRef); C;
  375. {$ELSEC}
  376.     JMSetTitleProcPtr = ProcPtr;
  377. {$ENDC}
  378.  
  379. {$IFC TYPED_FUNCTION_POINTERS}
  380.     JMCheckUpdateProcPtr = PROCEDURE(frame: JMFrameRef); C;
  381. {$ELSEC}
  382.     JMCheckUpdateProcPtr = ProcPtr;
  383. {$ENDC}
  384.  
  385. {$IFC TYPED_FUNCTION_POINTERS}
  386.     JMReorderFrame = PROCEDURE(frame: JMFrameRef; theRequest: ReorderRequest); C;
  387. {$ELSEC}
  388.     JMReorderFrame = ProcPtr;
  389. {$ENDC}
  390.  
  391. {$IFC TYPED_FUNCTION_POINTERS}
  392.     JMSetResizeable = PROCEDURE(frame: JMFrameRef; resizeable: BOOLEAN); C;
  393. {$ELSEC}
  394.     JMSetResizeable = ProcPtr;
  395. {$ENDC}
  396.  
  397.     JMFrameCallbacksPtr = ^JMFrameCallbacks;
  398.     JMFrameCallbacks = RECORD
  399.         fVersion:                UInt32;                                    {  should be set to kJMVersion  }
  400.         fSetFrameSize:            JMSetFrameSizeProcPtr;
  401.         fInvalRect:                JMFrameInvalRectProcPtr;
  402.         fShowHide:                JMFrameShowHideProcPtr;
  403.         fSetTitle:                JMSetTitleProcPtr;
  404.         fCheckUpdate:            JMCheckUpdateProcPtr;
  405.         fReorderFrame:            JMReorderFrame;
  406.         fSetResizeable:            JMSetResizeable;
  407.     END;
  408.  
  409. FUNCTION JMSetFrameVisibility(frame: JMFrameRef; famePort: GrafPtr; frameOrigin: Point; frameClip: RgnHandle): OSStatus; C;
  410. FUNCTION JMGetFrameData(frame: JMFrameRef; VAR data: JMClientData): OSStatus; C;
  411. FUNCTION JMSetFrameData(frame: JMFrameRef; data: JMClientData): OSStatus; C;
  412. FUNCTION JMGetFrameSize(frame: JMFrameRef; VAR result: Rect): OSStatus; C;
  413. { note that the top left indicates the "global" position of this frame }
  414. { use this to update the frame position when it gets moved }
  415. FUNCTION JMSetFrameSize(frame: JMFrameRef; {CONST}VAR newSize: Rect): OSStatus; C;
  416. {
  417.  * Dispatch a particular event to an embedded frame
  418.  }
  419. FUNCTION JMFrameClick(frame: JMFrameRef; localPos: Point; modifiers: INTEGER): OSStatus; C;
  420. FUNCTION JMFrameKey(frame: JMFrameRef; asciiChar: ByteParameter; keyCode: ByteParameter; modifiers: INTEGER): OSStatus; C;
  421. FUNCTION JMFrameKeyRelease(frame: JMFrameRef; asciiChar: ByteParameter; keyCode: ByteParameter; modifiers: INTEGER): OSStatus; C;
  422. FUNCTION JMFrameUpdate(frame: JMFrameRef; updateRgn: RgnHandle): OSStatus; C;
  423. FUNCTION JMFrameActivate(frame: JMFrameRef; activate: BOOLEAN): OSStatus; C;
  424. FUNCTION JMFrameResume(frame: JMFrameRef; resume: BOOLEAN): OSStatus; C;
  425. FUNCTION JMFrameMouseOver(frame: JMFrameRef; localPos: Point; modifiers: INTEGER): OSStatus; C;
  426. FUNCTION JMFrameShowHide(frame: JMFrameRef; showFrame: BOOLEAN): OSStatus; C;
  427. FUNCTION JMFrameGoAway(frame: JMFrameRef): OSStatus; C;
  428. FUNCTION JMGetFrameContext(frame: JMFrameRef): JMAWTContextRef; C;
  429. FUNCTION JMFrameDragTracking(frame: JMFrameRef; message: DragTrackingMessage; theDragRef: DragReference): OSStatus; C;
  430. FUNCTION JMFrameDragReceive(frame: JMFrameRef; theDragRef: DragReference): OSStatus; C;
  431. {
  432.  * Window types
  433.  }
  434.  
  435. TYPE
  436.     JMFrameKind                 = LONGINT;
  437. CONST
  438.     eBorderlessModelessWindowFrame = {JMFrameKind}0;
  439.     eModelessWindowFrame        = {JMFrameKind}1;
  440.     eModalWindowFrame            = {JMFrameKind}2;
  441.     eModelessDialogFrame        = {JMFrameKind}3;
  442.  
  443.  
  444.  
  445.  
  446. { JMAWTContext -
  447.  * To create a top level frame, you must use a JMAWTContext object.
  448.  * The JMAWTContext provides a context for the AWT to request frames.
  449.  * A AWTContext has a threadgroup associated with it - all events and processing occurs
  450.  * there.  When you create one, it is quiescent, you must call resume before it begins executing.
  451.  }
  452.  
  453. TYPE
  454. {$IFC TYPED_FUNCTION_POINTERS}
  455.     JMRequestFrameProcPtr = FUNCTION(context: JMAWTContextRef; newFrame: JMFrameRef; kind: JMFrameKind; {CONST}VAR initialBounds: Rect; resizeable: BOOLEAN; VAR callbacks: JMFrameCallbacks): OSStatus; C;
  456. {$ELSEC}
  457.     JMRequestFrameProcPtr = ProcPtr;
  458. {$ENDC}
  459.  
  460. {$IFC TYPED_FUNCTION_POINTERS}
  461.     JMReleaseFrameProcPtr = FUNCTION(context: JMAWTContextRef; oldFrame: JMFrameRef): OSStatus; C;
  462. {$ELSEC}
  463.     JMReleaseFrameProcPtr = ProcPtr;
  464. {$ENDC}
  465.  
  466. {$IFC TYPED_FUNCTION_POINTERS}
  467.     JMUniqueMenuIDProcPtr = FUNCTION(context: JMAWTContextRef; isSubmenu: BOOLEAN): SInt16; C;
  468. {$ELSEC}
  469.     JMUniqueMenuIDProcPtr = ProcPtr;
  470. {$ENDC}
  471.  
  472. {$IFC TYPED_FUNCTION_POINTERS}
  473.     JMExceptionOccurredProcPtr = PROCEDURE(context: JMAWTContextRef; exceptionName: JMTextRef; exceptionMsg: JMTextRef; stackTrace: JMTextRef); C;
  474. {$ELSEC}
  475.     JMExceptionOccurredProcPtr = ProcPtr;
  476. {$ENDC}
  477.  
  478.     JMAWTContextCallbacksPtr = ^JMAWTContextCallbacks;
  479.     JMAWTContextCallbacks = RECORD
  480.         fVersion:                UInt32;                                    {  should be set to kJMVersion  }
  481.         fRequestFrame:            JMRequestFrameProcPtr;                    {  a new frame is being created.  }
  482.         fReleaseFrame:            JMReleaseFrameProcPtr;                    {  an existing frame is being destroyed.  }
  483.         fUniqueMenuID:            JMUniqueMenuIDProcPtr;                    {  a new menu will be created with this id.  }
  484.         fExceptionOccurred:        JMExceptionOccurredProcPtr;                {  just some notification that some recent operation caused an exception.  You can't do anything really from here.  }
  485.     END;
  486.  
  487. FUNCTION JMNewAWTContext(VAR context: JMAWTContextRef; session: JMSessionRef; {CONST}VAR callbacks: JMAWTContextCallbacks; data: JMClientData): OSStatus; C;
  488. FUNCTION JMDisposeAWTContext(context: JMAWTContextRef): OSStatus; C;
  489. FUNCTION JMGetAWTContextData(context: JMAWTContextRef; VAR data: JMClientData): OSStatus; C;
  490. FUNCTION JMSetAWTContextData(context: JMAWTContextRef; data: JMClientData): OSStatus; C;
  491. FUNCTION JMCountAWTContextFrames(context: JMAWTContextRef; VAR frameCount: UInt32): OSStatus; C;
  492. FUNCTION JMGetAWTContextFrame(context: JMAWTContextRef; frameIndex: UInt32; VAR frame: JMFrameRef): OSStatus; C;
  493. FUNCTION JMMenuSelected(context: JMAWTContextRef; hMenu: MenuHandle; menuItem: INTEGER): OSStatus; C;
  494.  
  495.  
  496.  
  497. {
  498.  * JMAppletLocator - Since Java applets are always referenced by a Uniform Resource Locator
  499.  * (see RFC 1737, http://www.w3.org/pub/WWW/Addressing/rfc1738.txt), we provide an object
  500.  * that encapsulates the information about a set of applets. A JMAppletLocator is built
  501.  * by providing a base URL, which must point at a valid HTML document containing applet
  502.  * tags. To save a network transaction, the contents of the document may be passed optionally. 
  503.  *
  504.  * You can also use a JMLocatorInfoBlock for a synchronous resolution of the applet,
  505.  * assuming that you already have the info for the tag.
  506.  }
  507.  
  508. TYPE
  509.     JMLocatorErrors             = LONGINT;
  510. CONST
  511.     eLocatorNoErr                = {JMLocatorErrors}0;            {  the html was retrieved successfully }
  512.     eHostNotFound                = {JMLocatorErrors}1;            {  the host specified by the url could not be found }
  513.     eFileNotFound                = {JMLocatorErrors}2;            {  the file could not be found on the host }
  514.     eLocatorTimeout                = {JMLocatorErrors}3;            {  a timeout occurred retrieving the html text }
  515.     eLocatorKilled                = {JMLocatorErrors}4;            {  in response to a JMDisposeAppletLocator before it has completed }
  516.  
  517.  
  518. TYPE
  519. {$IFC TYPED_FUNCTION_POINTERS}
  520.     JMFetchCompleted = PROCEDURE(ref: JMAppletLocatorRef; status: JMLocatorErrors); C;
  521. {$ELSEC}
  522.     JMFetchCompleted = ProcPtr;
  523. {$ENDC}
  524.  
  525.     JMAppletLocatorCallbacksPtr = ^JMAppletLocatorCallbacks;
  526.     JMAppletLocatorCallbacks = RECORD
  527.         fVersion:                UInt32;                                    {  should be set to kJMVersion  }
  528.         fCompleted:                JMFetchCompleted;                        {  called when the html has been completely fetched  }
  529.     END;
  530.  
  531. {
  532.  * These structures are used to pass pre-parsed parameter
  533.  * tags to the AppletLocator.  Implies synchronous semantics.
  534.  }
  535.  
  536.     JMLIBOptionalParamsPtr = ^JMLIBOptionalParams;
  537.     JMLIBOptionalParams = RECORD
  538.         fParamName:                JMTextRef;                                {  could be from a <parameter name=foo value=bar> or "zipbase", etc  }
  539.         fParamValue:            JMTextRef;                                {  the value of this optional tag  }
  540.     END;
  541.  
  542.     JMLocatorInfoBlockPtr = ^JMLocatorInfoBlock;
  543.     JMLocatorInfoBlock = RECORD
  544.         fVersion:                UInt32;                                    {  should be set to kJMVersion  }
  545.                                                                         {  These are required to be present and not nil  }
  546.         fBaseURL:                JMTextRef;                                {  the URL of this applet's host page  }
  547.         fAppletCode:            JMTextRef;                                {  code= parameter  }
  548.         fWidth:                    INTEGER;                                {  width= parameter  }
  549.         fHeight:                INTEGER;                                {  height= parameter  }
  550.                                                                         {  These are optional parameters  }
  551.         fOptionalParameterCount: SInt32;                                {  how many in this array  }
  552.         fParams:                JMLIBOptionalParamsPtr;                    {  pointer to an array of these (points to first element)  }
  553.     END;
  554.  
  555. FUNCTION JMNewAppletLocator(VAR locatorRef: JMAppletLocatorRef; session: JMSessionRef; {CONST}VAR callbacks: JMAppletLocatorCallbacks; url: JMTextRef; htmlText: JMTextRef; data: JMClientData): OSStatus; C;
  556. FUNCTION JMNewAppletLocatorFromInfo(VAR locatorRef: JMAppletLocatorRef; session: JMSessionRef; {CONST}VAR info: JMLocatorInfoBlock; data: JMClientData): OSStatus; C;
  557. FUNCTION JMDisposeAppletLocator(locatorRef: JMAppletLocatorRef): OSStatus; C;
  558. FUNCTION JMGetAppletLocatorData(locatorRef: JMAppletLocatorRef; VAR data: JMClientData): OSStatus; C;
  559. FUNCTION JMSetAppletLocatorData(locatorRef: JMAppletLocatorRef; data: JMClientData): OSStatus; C;
  560. FUNCTION JMCountApplets(locatorRef: JMAppletLocatorRef; VAR appletCount: UInt32): OSStatus; C;
  561. FUNCTION JMGetAppletDimensions(locatorRef: JMAppletLocatorRef; appletIndex: UInt32; VAR width: UInt32; VAR height: UInt32): OSStatus; C;
  562. FUNCTION JMGetAppletTag(locatorRef: JMAppletLocatorRef; appletIndex: UInt32; VAR tagRef: JMTextRef): OSStatus; C;
  563. FUNCTION JMGetAppletName(locatorRef: JMAppletLocatorRef; appletIndex: UInt32; VAR nameRef: JMTextRef): OSStatus; C;
  564.  
  565. {
  566.  * JMAppletViewer - Applets are instantiated, one by one, by specifying a JMAppletLocator and
  567.  * a zero-based index (Macintosh API's usually use one-based indexing, the Java language
  568.  * uses zero, however.). The resulting applet is encapsulated in a JMAppletViewer object. 
  569.  * Since applets can have one or more visible areas to draw in, one or more JMFrame objects
  570.  * may be requested while the viewer is being created, or at a later time, thus the client
  571.  * must provide callbacks to satisfy these requests.
  572.  *
  573.  * The window name for the ShowDocument callback is one of:
  574.  *   _self        show in current frame
  575.  *   _parent    show in parent frame
  576.  *   _top        show in top-most frame
  577.  *   _blank        show in new unnamed top-level window
  578.  *   <other>    show in new top-level window named <other> 
  579.  }
  580.  
  581. TYPE
  582. {$IFC TYPED_FUNCTION_POINTERS}
  583.     JMShowDocumentProcPtr = PROCEDURE(viewer: JMAppletViewerRef; urlString: JMTextRef; windowName: JMTextRef); C;
  584. {$ELSEC}
  585.     JMShowDocumentProcPtr = ProcPtr;
  586. {$ENDC}
  587.  
  588. {$IFC TYPED_FUNCTION_POINTERS}
  589.     JMSetStatusMsgProcPtr = PROCEDURE(viewer: JMAppletViewerRef; statusMsg: JMTextRef); C;
  590. {$ELSEC}
  591.     JMSetStatusMsgProcPtr = ProcPtr;
  592. {$ENDC}
  593.  
  594.     JMAppletViewerCallbacksPtr = ^JMAppletViewerCallbacks;
  595.     JMAppletViewerCallbacks = RECORD
  596.         fVersion:                UInt32;                                    {  should be set to kJMVersion  }
  597.         fShowDocument:            JMShowDocumentProcPtr;                    {  go to a url, optionally in a new window  }
  598.         fSetStatusMsg:            JMSetStatusMsgProcPtr;                    {  applet changed status message  }
  599.     END;
  600.  
  601. {
  602.  * NEW: per-applet security settings
  603.  * Previously, these settings were attached to the session.
  604.  * JManager 2.0 allows them to be attached to each viewer.
  605.  }
  606.     JMNetworkSecurityOptions     = LONGINT;
  607. CONST
  608.     eNoNetworkAccess            = {JMNetworkSecurityOptions}0;
  609.     eAppletHostAccess            = {JMNetworkSecurityOptions}1;
  610.     eUnrestrictedAccess            = {JMNetworkSecurityOptions}2;
  611.  
  612.  
  613. TYPE
  614.     JMFileSystemOptions         = LONGINT;
  615. CONST
  616.     eNoFSAccess                    = {JMFileSystemOptions}0;
  617.     eLocalAppletAccess            = {JMFileSystemOptions}1;
  618.     eAllFSAccess                = {JMFileSystemOptions}2;
  619.  
  620. {
  621.  * Lists of packages are comma separated,
  622.  * the default for mrj.security.system.access is
  623.  * "sun,netscape,com.apple".
  624.  }
  625.  
  626.  
  627. TYPE
  628.     JMAppletSecurityPtr = ^JMAppletSecurity;
  629.     JMAppletSecurity = RECORD
  630.         fVersion:                UInt32;                                    {  should be set to kJMVersion  }
  631.         fNetworkSecurity:        JMNetworkSecurityOptions;                {  can this applet access network resources  }
  632.         fFileSystemSecurity:    JMFileSystemOptions;                    {  can this applet access network resources  }
  633.         fRestrictSystemAccess:    BOOLEAN;                                {  restrict access to system packages (com.apple.*, sun.*, netscape.*) also found in the property "mrj.security.system.access"  }
  634.         fRestrictSystemDefine:    BOOLEAN;                                {  restrict classes from loading system packages (com.apple.*, sun.*, netscape.*) also found in the property "mrj.security.system.define"  }
  635.         fRestrictApplicationAccess: BOOLEAN;                            {  restrict access to application packages found in the property "mrj.security.application.access"  }
  636.         fRestrictApplicationDefine: BOOLEAN;                            {  restrict access to application packages found in the property "mrj.security.application.access"  }
  637.     END;
  638.  
  639. {
  640.  * AppletViewer methods
  641.  }
  642. FUNCTION JMNewAppletViewer(VAR viewer: JMAppletViewerRef; context: JMAWTContextRef; locatorRef: JMAppletLocatorRef; appletIndex: UInt32; {CONST}VAR security: JMAppletSecurity; {CONST}VAR callbacks: JMAppletViewerCallbacks; data: JMClientData): OSStatus; C;
  643. FUNCTION JMDisposeAppletViewer(viewer: JMAppletViewerRef): OSStatus; C;
  644. FUNCTION JMGetAppletViewerData(viewer: JMAppletViewerRef; VAR data: JMClientData): OSStatus; C;
  645. FUNCTION JMSetAppletViewerData(viewer: JMAppletViewerRef; data: JMClientData): OSStatus; C;
  646.  
  647. {
  648.  * You can change the applet security on the fly
  649.  }
  650. FUNCTION JMGetAppletViewerSecurity(viewer: JMAppletViewerRef; VAR data: JMAppletSecurity): OSStatus; C;
  651. FUNCTION JMSetAppletViewerSecurity(viewer: JMAppletViewerRef; {CONST}VAR data: JMAppletSecurity): OSStatus; C;
  652.  
  653. {
  654.  * JMReloadApplet reloads viewer's applet from the source.
  655.  * JMRestartApplet reinstantiates the applet without reloading.
  656.  }
  657. FUNCTION JMReloadApplet(viewer: JMAppletViewerRef): OSStatus; C;
  658. FUNCTION JMRestartApplet(viewer: JMAppletViewerRef): OSStatus; C;
  659.  
  660. {
  661.  * JMSuspendApplet tells the Java thread scheduler to stop executing the viewer's applet.
  662.  * JMResumeApplet resumes execution of the viewer's applet.
  663.  }
  664. FUNCTION JMSuspendApplet(viewer: JMAppletViewerRef): OSStatus; C;
  665. FUNCTION JMResumeApplet(viewer: JMAppletViewerRef): OSStatus; C;
  666.  
  667.  * To get back to the JMAppletViewerRef instance from whence a frame came,
  668.  * as well as the ultimate frame parent (the one created _for_ the applet viewer)
  669.  }
  670. FUNCTION JMGetFrameViewer(frame: JMFrameRef; VAR viewer: JMAppletViewerRef; VAR parentFrame: JMFrameRef): OSStatus; C;
  671. {
  672.  * To get a ref back to the Frame that was created for this JMAppletViewerRef
  673.  }
  674. FUNCTION JMGetViewerFrame(viewer: JMAppletViewerRef; VAR frame: JMFrameRef): OSStatus; C;
  675. {$ALIGN RESET}
  676. {$POP}
  677.  
  678. {$SETC UsingIncludes := JManagerIncludes}
  679.  
  680. {$ENDC} {__JMANAGER__}
  681.  
  682. {$IFC NOT UsingIncludes}
  683.  END.
  684. {$ENDC}
  685.